<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/head :: head(links)"/>
<body>
<div class="ok-body" id="app" v-cloak>
    <template>
        <i-form ref="checkForm" :model="user" :rules="ruleValidate" :label-width="100">
            <form-item prop="oldPassword" label="原密码：">
                <i-input type="password" maxlength="20" v-model="user.oldPassword" placeholder="请输入原密码"></i-input>
            </form-item>
            <form-item prop="password" label="新密码：">
                <i-input type="password" maxlength="20" v-model="user.password" placeholder="请输入新密码"></i-input>
            </form-item>
            <form-item prop="newPassword" label="新密码：">
                <i-input type="password" maxlength="20" v-model="user.newPassword" placeholder="再次输入新密码"></i-input>
            </form-item>
        </i-form>
    </template>
</div>
<div th:replace="common/foot :: foot(script)"></div>
<script th:inline="none">
    var vm = new Vue({
        el: '#app',
        data:{
            user:{
                password: '',
            },
            ruleValidate : {
                oldPassword: [
                    { required: true, message: '原密码不能为空', trigger: 'blur' }
                ],
                password: [
                    { required: true, message: '新密码不能为空', trigger: 'blur' }
                ],
                newPassword: [
                    { required: true, message: '新密码不能为空', trigger: 'blur' }
                ]
            },
            okUtils:null,
            okLayer:null
        },
        methods: {
            load : function(){

            },
            acceptClick : function(){
                vm.$refs.checkForm.validate(function(valid){
                    if (valid) {
                        layui.use(["okUtils", "okLayer"], function () {
                            vm.okUtils = layui.okUtils;
                            vm.okLayer = layui.okLayer;
                            if(vm.user.password!=vm.user.newPassword){
                                okLayer.msg.yellowQuestion("新密码不一致！！！");
                            }
                            vm.okUtils.ajaxCloud({
                                url:"/sys/user/updatePwd",
                                param: vm.user,
                                success : function(result) {
                                    vm.okLayer.msg.greenTick(result.msg)
                                }
                            });
                        });
                    }
                });
            }
        },
        created: function() {

        }
    });
</script>
</body>
</html>
